﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using javabank;

public partial class _Default : System.Web.UI.Page
{
    JavabankWebService javabank = new JavabankWebService();

    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Visible = false;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        account ac = new account();
        ac.naam = TextBox1.Text;
        ac.woonplaats = TextBox2.Text;
        ac.rekeningnummer = Convert.ToInt32(TextBox3.Text);
        ac.saldo = float.Parse(TextBox4.Text);
        ac.limiet = float.Parse(TextBox5.Text);
        javabank.openAccount(ac);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        int reknrFrom = Convert.ToInt32(TextBox6.Text);
        int reknrTo = Convert.ToInt32(TextBox7.Text);
        float amount = float.Parse(TextBox8.Text);

        bool success = javabank.transfer(amount, reknrFrom, reknrTo);
        Label1.Text = "Success: " + success;
        Label1.Visible = true;
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        int rekeningNummer = Convert.ToInt32(TextBox9.Text);

        account ac = javabank.getAccount(rekeningNummer);

        BulletedList2.Items.Add("Naam: " + ac.naam);
        BulletedList2.Items.Add("Woonplaats: " + ac.woonplaats);
        BulletedList2.Items.Add("Rekeningnummer: " + ac.rekeningnummer);
        BulletedList2.Items.Add("Saldo: " + ac.saldo);
        BulletedList2.Items.Add("Limiet: " + ac.limiet);
    }

    protected void Button4_Click(object sender, EventArgs e)
    {
        account ac = new account();
        ac.naam = TextBox1.Text;
        ac.woonplaats = TextBox2.Text;
        ac.rekeningnummer = Convert.ToInt32(TextBox3.Text);
        ac.saldo = (float)Convert.ToDouble(TextBox4.Text);
        ac.limiet = (float)Convert.ToDouble(TextBox5.Text);

        javabank.alterAccount(ac);
    }
    protected void Button5_Click(object sender, EventArgs e){

        
        int rekeningnummer = Convert.ToInt32(TextBox15.Text);
        String datum = TextBox16.Text;

        transactie[] ts = javabank.getTransactions(rekeningnummer, datum);

        foreach(transactie t in ts){
            BulletedList1.Items.Add("€" + t.bedrag + " van " + t.verzender + " naar " + t.ontvanger + " op " + t.datum);
        }
    }

}